package com.qf.index;

import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpException;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.qf.http.HttpClientConfig;
import com.qf.http.HttpClientUtil;
import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 翻译接口，含阿里的和有道的。
 * 贾新志 2024.02.29
 */
public class TransApi {
    public static void main(String[] args) {

        String s = youDaoCnToEnTrans("中国华西医院");
        String t = youDaoEnToCnTrans("Genome analysis-based reclassification of Enterobacter tabaci Duan et al. 2016 as a later heterotypic synonym of Enterobacter mori Zhu et al. 2011.");
        System.out.println("s: " + s);
        System.out.println("t: " + t);

// main
    }

    // 有道中转英翻译
    public static String youDaoCnToEnTrans(String str) {
//        return "翻译准备切换，请等待新的翻译模型。";
        if (null != str && !str.isEmpty()) {
            // 为什么删除"&"？因为有道翻译时，会把"&"符号后面的翻译给忽略。2024.02.05
            str = str.replace("&", " ").replaceAll("<[^>]+>", "");
            str = str.replace("\r","");
            str = str.replace("\n","");
            Map<String, Object> paramMap = new LinkedHashMap<>();
            paramMap.put("q", str);
            paramMap.put("from", "zh-CHS");
            paramMap.put("to", "en");
            try {
                return HttpUtil.post("https://fanyi.yuntsg.com/v2/translate_a", paramMap);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return "";
    }

    // 有道英转中翻译
    public static String youDaoEnToCnTrans(String str) {
//        return "翻译准备切换，请等待新的翻译模型。";
        if (null != str && !str.isEmpty()) {
            // 为什么删除"&"？因为有道翻译时，会把"&"符号后面的翻译给忽略。2024.02.05
            str = str.replace("&", " ").replaceAll("<[^>]+>", "");
            str = str.replace("\r","");
            str = str.replace("\n","");
            Map<String, Object> paramMap = new LinkedHashMap<>();
            paramMap.put("q", str);
            paramMap.put("from", "en");
            paramMap.put("to", "zh-CHS");
            try {
                return HttpUtil.post("https://fanyi.yuntsg.com/v2/translate_a", paramMap);
            } catch (Exception e) {
//                e.printStackTrace();
            }
        }
        return "";
    }



    // 执行翻译，enStr是待翻译的英文字符串，max是每次提交给翻译模型的最大单词数量，提交时以句号为切割点，句子的集合一般不大于100个单词，如果发生翻译的数量不对，则返回为空字符串。GPUList是模型GPU的集合。
    public static String aLiEnToCnTrans(String enStr, int max, List<String> gpuList) {
        List<TransInfoLog> errLogList = new ArrayList<>();
        enStr = enStr.replace("。", ".").replace("，", ",").replace("；", ";").replace("？", "?").replace("：", ":").replaceAll(" +", " ").trim() + " ";
        String[] split = enStr.split(" ");
        List<String> list = new ArrayList<>();
        if (split.length < max) {
            list.add(enStr);
            String translate = getTranslate(list, " ", gpuList, errLogList);
            // 如果有翻译的错误日志，则直接返回空字符串。
            return !errLogList.isEmpty() ? "" : translate;
        } else {
            // 以句号加空格进行切割
            String[] firstSplit = enStr.split("\\. ");
            int sum = 0;
            StringBuilder result = new StringBuilder();
            for (String first : firstSplit) {
                int length = first.split(" ").length;
                if (length > max - 1) {
                    first = first.replace(", ", "㵝. ").replace("? ", "纃. ").replace("; ", "☷. ").replaceAll(" +", " ").trim();
                    // 如果以空格切割的单词数量比设定值多，则将逗号、句号、分号替换为句号，再次以句号进行切割，此为第二种情况，即单以句号仍大于设定值。
                    String[] middleSplit = first.split("\\. ");
                    for (int i = 0; i < middleSplit.length; i++) {
                        String middle = middleSplit[i];
                        // 特殊字符"㵝"、"纃"、"☷"的作用是，先将逗号、句号、分号替换为句号，执行切割后，再还原回来。
                        middle = middle.replace("㵝", ", ").replace("☷", "; ").replace("纃", "? ").replaceAll(" +", " ").trim();
                        middle = (i + 1 == middleSplit.length) ? (middle + ". ") : middle;
                        int len = middle.split(" ").length;
                        if (len > max - 1) {
                            // 第三种，如果第二种仍大于设定值，则再次空格切割，而这一次要么直接翻译，要么添加，确保不会出现漏翻译的情况。
                            String[] lastSplit = middle.split(" ");
                            for (String last : lastSplit) {
                                if (sum + 1 < max) {
                                    list.add(last + " ");
                                    sum += 1;
                                } else {
                                    result.append(getTranslate(list, " ", gpuList, errLogList));
                                    sum = 1;
                                    list.clear();
                                    list.add(last + " ");
                                }
                            }
                        } else if (sum + len < max) {
                            list.add(middle);
                            sum += len;
                        } else {
                            result.append(getTranslate(list, " ", gpuList, errLogList));
                            sum = 0;
                            list.clear();
                            list.add(middle);
                            sum += len;
                        }
                    }
                    // 如果原来的以空格进行切割的单词数量总和，加上本次的以空格进行切割的单词数量，仍小于设定值，则直接添加到待翻译里面。否则先把待翻译的执行翻译，再把待翻译的清空，再把总和的置0，再把本次的添加到待翻译中，再把总和的加上本次的数量。
                } else if (sum + length < max) {
                    list.add(first + ". ");
                    sum += length;
                } else {
                    result.append(getTranslate(list, " ", gpuList, errLogList));
                    sum = 0;
                    list.clear();
                    list.add(first + ". ");
                    sum += length;
                }
            }
            result.append(getTranslate(list, " ", gpuList, errLogList));
            return !errLogList.isEmpty() ? "" : result.toString();
        }
    }


    public static String aLiEnToCnTransBySingleYouDao(String enStr, int max,boolean iscn) {
        List<TransInfoLog> errLogList = new ArrayList<>();
        // 中英文判断字符不一样需要分开判断拆解
        enStr = enStr.replace("。", ".").replace("，", ",").replace("；", ";").replace("？", "?").replace("：", ":").replaceAll(" +", " ").trim() + " ";

        List<String> list = new ArrayList<>();
        if (enStr.length() < max) {
            list.add(enStr);
            String translate = getTranslateByYoudao(list, " ", iscn, errLogList);
            // 如果有翻译的错误日志，则直接返回空字符串。
            return !errLogList.isEmpty() ? "" : translate;
        } else {
            // 以句号加空格进行切割
            String sp = " ";
            if (iscn) {
                sp = "";
            }
            String[] firstSplit = enStr.split("\\. ");
            int sum = 0;
            StringBuilder result = new StringBuilder();
            for (String first : firstSplit) {
                int length = first.split(sp).length;
                if (length > max - 1) {
                    first = first.replace(", ", "㵝. ").replace("? ", "纃. ").replace("; ", "☷. ").replaceAll(" +", " ").trim();
                    // 如果以空格切割的单词数量比设定值多，则将逗号、句号、分号替换为句号，再次以句号进行切割，此为第二种情况，即单以句号仍大于设定值。
                    String[] middleSplit = first.split("\\. ");
                    for (int i = 0; i < middleSplit.length; i++) {
                        String middle = middleSplit[i];
                        // 特殊字符"㵝"、"纃"、"☷"的作用是，先将逗号、句号、分号替换为句号，执行切割后，再还原回来。
                        middle = middle.replace("㵝", ", ").replace("☷", "; ").replace("纃", "? ").replaceAll(" +", " ").trim();
                        middle = (i + 1 == middleSplit.length) ? (middle + ". ") : middle;
                        int len = middle.split(sp).length;
                        if (len > max - 1) {
                            // 第三种，如果第二种仍大于设定值，则再次空格切割，而这一次要么直接翻译，要么添加，确保不会出现漏翻译的情况。
                            String[] lastSplit = middle.split(sp);
                            for (String last : lastSplit) {
                                if (sum + 1 < max) {
                                    list.add(last + sp);
                                    sum += 1;
                                } else {
                                    result.append(getTranslateByYoudao(list, " ", iscn, errLogList));
                                    sum = 1;
                                    list.clear();
                                    list.add(last + " ");
                                }
                            }
                        } else if (sum + len < max) {
                            list.add(middle);
                            sum += len;
                        } else {
                            result.append(getTranslateByYoudao(list, " ", iscn, errLogList));
                            sum = 0;
                            list.clear();
                            list.add(middle);
                            sum += len;
                        }
                    }
                    // 如果原来的以空格进行切割的单词数量总和，加上本次的以空格进行切割的单词数量，仍小于设定值，则直接添加到待翻译里面。否则先把待翻译的执行翻译，再把待翻译的清空，再把总和的置0，再把本次的添加到待翻译中，再把总和的加上本次的数量。
                } else if (sum + length < max) {
                    list.add(first + ". ");
                    sum += length;
                } else {
                    result.append(getTranslateByYoudao(list, " ", iscn, errLogList));
                    sum = 0;
                    list.clear();
                    list.add(first + ". ");
                    sum += length;
                }
            }
            result.append(getTranslateByYoudao(list, " ", iscn, errLogList));
            return !errLogList.isEmpty() ? "" : result.toString();
        }
    }

    @Data
    // 翻译日志记录信息，包含一个英文和一个中文的集合，当英文的句子多于中文的句子时，说明漏翻译了。
    public static class TransInfoLog {
        private List<String> enList = new ArrayList<>();
        private List<String> cnList = new ArrayList<>();
    }

    // 英到中的翻译主体，如果有漏翻译的，返回为空字符串。每一个英文句子的集合，一般不大于100个句子，且不可以将多个英文句子整理为一个句子给翻译模型，只能是一个句子一个句子的添加到集合中。
    public static List<String> enToCnTrans(List<String> gpuList, List<String> enList, List<TransInfoLog> errLogList) {
        Map<String, Object> map1 = new HashMap<>();
        map1.put("from", "en");
        map1.put("to", "zh");
        map1.put("q", enList);
        try {
            HttpClientConfig clientConfig = new HttpClientConfig()
                    .setUrl(gpuList.get(RandomUtil.randomInt(0, gpuList.size())))
                    .setContentType("application/json")
                    .setPostDate(JSONUtil.toJsonStr(map1))
                    .build();
            String body = HttpClientUtil.post(clientConfig);
            if (StrUtil.isNotBlank(body)) {
                List<String> cnList = JSONUtil.toList(JSONUtil.parseArray(body), String.class);
                // 理论上，一个英文句子，翻译后只对应一个中文句子，如果数量不相等，可能是有漏翻译的，记录到翻译错误日志中。
                if (cnList.size() == enList.size()) {
                    return cnList;
                } else {
                    TransInfoLog transInfoLog = new TransInfoLog();
                    transInfoLog.setEnList(enList);
                    transInfoLog.setCnList(cnList);
                    errLogList.add(transInfoLog);
                }
            }
        } catch (HttpException e) {
//            e.printStackTrace();
        }
        return new ArrayList<>();
    }

    // 执行翻译方法中的一个方法，功能是对英文集合进行翻译，并返回连接到一块儿的中文句子。
    public static String getTranslate(List<String> enList, String end, List<String> gpuList, List<TransInfoLog> errLogList) {
        StringBuilder result = new StringBuilder();
        List<String> cnList = enToCnTrans(gpuList, enList, errLogList);
        for (String s : cnList) {
            result.append(s).append(end);
        }
        return result.toString().replace(" （ ", "（").replace(" ） ", "）").replace(" ， ", "，").replace(" ： ", "：").replace(" / / ", "//")
                .replace(" / ", "/").replace(" > < ", "><").replace(" > ", ">").replace(" < ", "<").replace(" \\ ", "\\").replace("\\ ", "\\")
                .replace("。", ".").replace(". ", "。 ").replace("。。 ", "。 ").replace(" - ", "-").replace("）- ", "）-").replace(" ； ", "； ").replace(" 、 ", "、");
    }

    public static String getTranslateByYoudao(List<String> enList, String end, boolean isCn, List<TransInfoLog> errLogList) {
        StringBuilder result = new StringBuilder();
        for (String s : enList) {
            if (!isCn) {
                String s1 = TransApi.youDaoEnToCnTrans(s);
                result.append(s1).append(end);
            }else {
                String s1 = TransApi.youDaoCnToEnTrans(s);
                result.append(s1).append(end);
            }

        }
        return result.toString().replace(" （ ", "（").replace(" ） ", "）").replace(" ， ", "，").replace(" ： ", "：").replace(" / / ", "//")
                .replace(" / ", "/").replace(" > < ", "><").replace(" > ", ">").replace(" < ", "<").replace(" \\ ", "\\").replace("\\ ", "\\")
                .replace("。", ".").replace(". ", "。 ").replace("。。 ", "。 ").replace(" - ", "-").replace("）- ", "）-").replace(" ； ", "； ").replace(" 、 ", "、");
    }

    // 阿里翻译模型的GPU链接集合
    public static List<String> getGpuList() {
        List<String> gpuList = new ArrayList<>();
        gpuList.add("http://123.128.12.90:9001/fanyi");
        gpuList.add("http://123.128.12.90:9002/fanyi");
//        gpuList.add("http://123.128.12.90:9003/fanyi"); // 2024.08.31 显示报错
        gpuList.add("http://123.128.12.90:9004/fanyi");
        gpuList.add("http://123.128.12.90:9005/fanyi");
        gpuList.add("http://123.128.12.90:9006/fanyi");
        gpuList.add("http://123.128.12.90:9007/fanyi");
        gpuList.add("http://123.128.12.90:9008/fanyi");
        return gpuList;
    }

    public static List<String> getGpuList3090() {
        List<String> gpuList = new ArrayList<>();
        gpuList.add("http://123.128.12.90:9101/fanyi");
        gpuList.add("http://123.128.12.90:9102/fanyi");
        gpuList.add("http://123.128.12.90:9103/fanyi");
        gpuList.add("http://123.128.12.90:9104/fanyi");
        gpuList.add("http://123.128.12.90:9105/fanyi");
        gpuList.add("http://123.128.12.90:9106/fanyi");
        gpuList.add("http://123.128.12.90:9107/fanyi");
        gpuList.add("http://123.128.12.90:9108/fanyi");
        return gpuList;
    }

    public static void test4() {
        List<String> gpuList = new ArrayList<>();
        gpuList.add("http://123.128.12.90:9101/fanyi");
        gpuList.add("http://123.128.12.90:9102/fanyi");
        gpuList.add("http://123.128.12.90:9103/fanyi");
        gpuList.add("http://123.128.12.90:9104/fanyi");
        gpuList.add("http://123.128.12.90:9105/fanyi");
        gpuList.add("http://123.128.12.90:9106/fanyi");
        gpuList.add("http://123.128.12.90:9107/fanyi");
        gpuList.add("http://123.128.12.90:9108/fanyi");
        String enStr = "Transforming growth factor β (TGF-β) has long been identified with its intensive involvement in early embryonic development and organogenesis, immune supervision, tissue repair, and adult homeostasis. The role of TGF-β in fibrosis and cancer is complex and sometimes even contradictory, exhibiting either inhibitory or promoting effects depending on the stage of the disease. Under pathological conditions, overexpressed TGF-β causes epithelial-mesenchymal transition (EMT), extracellular matrix (ECM) deposition, cancer-associated fibroblast (CAF) formation, which leads to fibrotic disease, and cancer. Given the critical role of TGF-β and its downstream molecules in the progression of fibrosis and cancers, therapeutics targeting TGF-β signaling appears to be a promising strategy. However, due to potential systemic cytotoxicity, the development of TGF-β therapeutics has lagged. In this review, we summarized the biological process of TGF-β, with its dual role in " +
                "fibrosis and tumorigenesis, and the clinical application of TGF-β-targeting therapies. The transforming growth factor-β (TGF-β) is the prototype of the TGF-β family of growth and differentiation factors, which is encoded by 33 genes in mammals and comprises homo- and heterodimers. This review introduces the reader to the TGF-β family with its complexity of names and biological activities. It also introduces TGF-β as the best-studied factor among the TGF-β family proteins, with its diversity of roles in the control of cell proliferation and differentiation, wound healing and immune system, and its key roles in pathology, for example, skeletal diseases, fibrosis, and cancer. Introduction: Transforming Growth Factor-Beta (TGF-β) is a master regulator of numerous cellular functions including cellular immunity. In cancer, TGF-β can function as a tumor promoter via several mechanisms including immunosuppression. Since the immune checkpoint pathways are co-opted in cancer " +
                "to induce T cell tolerance, this review posits that TGF-β is a master checkpoint in cancer, whose negative regulatory influence overrides and controls that of other immune checkpoints.Areas Covered: This review examines therapeutic agents that target TGF-β and its signaling pathways for the treatment of cancer which may be classifiable as checkpoint inhibitors in the broadest sense. This concept is supported by the observations that 1) only a subset of patients benefit from current checkpoint inhibitor therapies, 2) the presence of TGF-β in the tumor microenvironment is associated with excluded or cold tumors, and resistance to checkpoint inhibitors, and 3) existing biomarkers such as PD-1, PD-L1, microsatellite instability and tumor mutational burden are inadequate to reliably and adequately identify immuno-responsive patients. By contrast, TGF-β overexpression is a widespread and profoundly negative molecular hallmark in multiple tumor types.Expert Opinion: TGF-β " +
                "status may serve as a biomarker to predict responsiveness and as a therapeutic target to increase the activity of immunotherapies. The TGF-beta family of cytokines are ubiquitous, multifunctional and essential to survival. They play important roles in growth and development, inflammation and repair and host immunity. The mammalian TGF-beta isoforms (TGF-beta 1, beta 2 and beta 3) are secreted as latent precursors and have multiple cell surface receptors of which at least two mediate signal transduction. Autocrine and paracrine effects of TGF-beta's can be modified by extracellular matrix, neighbouring cells and other cytokines. The vital role of the TGF-beta family is illustrated by the fact that approximately 50% of TGF-beta 1 gene knockout mice die in utero and the remainder succumb to uncontrolled inflammation after birth. TGF-beta 2 and TGF-beta 3 gene knockout mice are not yet described. More recently, novel TGF-beta-like molecules have been described which " +
                "share some of the properties of the mammalian TGF-beta isoforms. The role of TGF-beta in homeostatic and pathogenic processes suggests numerous applications in the diagnosis and treatment of various diseases characterised by inflammation and fibrosis.";
        for (String s : gpuList) {
            List<String> list = new ArrayList<>();
            list.add(s);
            String cnStr0 = aLiEnToCnTrans(enStr, 100, list);
            System.out.println("cnStr0:" + cnStr0 + " gpu:" + s);
            System.out.println(" ");
        }
    }

    public static void test3() {
        List<String> gpuList = new ArrayList<>();
        gpuList.add("http://123.128.12.90:9001/fanyi");
        gpuList.add("http://123.128.12.90:9002/fanyi");
        gpuList.add("http://123.128.12.90:9003/fanyi");
        gpuList.add("http://123.128.12.90:9004/fanyi");
        gpuList.add("http://123.128.12.90:9005/fanyi");
        gpuList.add("http://123.128.12.90:9006/fanyi");
        gpuList.add("http://123.128.12.90:9007/fanyi");
        gpuList.add("http://123.128.12.90:9008/fanyi");
        String enStr = "Transforming growth factor β (TGF-β) has long been identified with its intensive involvement in early embryonic development and organogenesis, immune supervision, tissue repair, and adult homeostasis. The role of TGF-β in fibrosis and cancer is complex and sometimes even contradictory, exhibiting either inhibitory or promoting effects depending on the stage of the disease. Under pathological conditions, overexpressed TGF-β causes epithelial-mesenchymal transition (EMT), extracellular matrix (ECM) deposition, cancer-associated fibroblast (CAF) formation, which leads to fibrotic disease, and cancer. Given the critical role of TGF-β and its downstream molecules in the progression of fibrosis and cancers, therapeutics targeting TGF-β signaling appears to be a promising strategy. However, due to potential systemic cytotoxicity, the development of TGF-β therapeutics has lagged. In this review, we summarized the biological process of TGF-β, with its dual role in " +
                "fibrosis and tumorigenesis, and the clinical application of TGF-β-targeting therapies. The transforming growth factor-β (TGF-β) is the prototype of the TGF-β family of growth and differentiation factors, which is encoded by 33 genes in mammals and comprises homo- and heterodimers. This review introduces the reader to the TGF-β family with its complexity of names and biological activities. It also introduces TGF-β as the best-studied factor among the TGF-β family proteins, with its diversity of roles in the control of cell proliferation and differentiation, wound healing and immune system, and its key roles in pathology, for example, skeletal diseases, fibrosis, and cancer. Introduction: Transforming Growth Factor-Beta (TGF-β) is a master regulator of numerous cellular functions including cellular immunity. In cancer, TGF-β can function as a tumor promoter via several mechanisms including immunosuppression. Since the immune checkpoint pathways are co-opted in cancer " +
                "to induce T cell tolerance, this review posits that TGF-β is a master checkpoint in cancer, whose negative regulatory influence overrides and controls that of other immune checkpoints.Areas Covered: This review examines therapeutic agents that target TGF-β and its signaling pathways for the treatment of cancer which may be classifiable as checkpoint inhibitors in the broadest sense. This concept is supported by the observations that 1) only a subset of patients benefit from current checkpoint inhibitor therapies, 2) the presence of TGF-β in the tumor microenvironment is associated with excluded or cold tumors, and resistance to checkpoint inhibitors, and 3) existing biomarkers such as PD-1, PD-L1, microsatellite instability and tumor mutational burden are inadequate to reliably and adequately identify immuno-responsive patients. By contrast, TGF-β overexpression is a widespread and profoundly negative molecular hallmark in multiple tumor types.Expert Opinion: TGF-β " +
                "status may serve as a biomarker to predict responsiveness and as a therapeutic target to increase the activity of immunotherapies. The TGF-beta family of cytokines are ubiquitous, multifunctional and essential to survival. They play important roles in growth and development, inflammation and repair and host immunity. The mammalian TGF-beta isoforms (TGF-beta 1, beta 2 and beta 3) are secreted as latent precursors and have multiple cell surface receptors of which at least two mediate signal transduction. Autocrine and paracrine effects of TGF-beta's can be modified by extracellular matrix, neighbouring cells and other cytokines. The vital role of the TGF-beta family is illustrated by the fact that approximately 50% of TGF-beta 1 gene knockout mice die in utero and the remainder succumb to uncontrolled inflammation after birth. TGF-beta 2 and TGF-beta 3 gene knockout mice are not yet described. More recently, novel TGF-beta-like molecules have been described which " +
                "share some of the properties of the mammalian TGF-beta isoforms. The role of TGF-beta in homeostatic and pathogenic processes suggests numerous applications in the diagnosis and treatment of various diseases characterised by inflammation and fibrosis.";
        for (String s : gpuList) {
            List<String> list = new ArrayList<>();
            list.add(s);
            String cnStr0 = aLiEnToCnTrans(enStr, 100, list);
            System.out.println("cnStr0:" + cnStr0 + " gpu:" + s);
            System.out.println(" ");
        }
    }

    public static void test1() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(format.format(new Date()) + " 程序开始了~~~");
        long t0 = System.currentTimeMillis();
        List<String> gpuList = getGpuList();
        String enStr = "Transforming growth factor β (TGF-β) has long been identified with its intensive involvement in early embryonic development and organogenesis, immune supervision, tissue repair, and adult homeostasis. The role of TGF-β in fibrosis and cancer is complex and sometimes even contradictory, exhibiting either inhibitory or promoting effects depending on the stage of the disease. Under pathological conditions, overexpressed TGF-β causes epithelial-mesenchymal transition (EMT), extracellular matrix (ECM) deposition, cancer-associated fibroblast (CAF) formation, which leads to fibrotic disease, and cancer. Given the critical role of TGF-β and its downstream molecules in the progression of fibrosis and cancers, therapeutics targeting TGF-β signaling appears to be a promising strategy. However, due to potential systemic cytotoxicity, the development of TGF-β therapeutics has lagged. In this review, we summarized the biological process of TGF-β, with its dual role in " +
                "fibrosis and tumorigenesis, and the clinical application of TGF-β-targeting therapies. The transforming growth factor-β (TGF-β) is the prototype of the TGF-β family of growth and differentiation factors, which is encoded by 33 genes in mammals and comprises homo- and heterodimers. This review introduces the reader to the TGF-β family with its complexity of names and biological activities. It also introduces TGF-β as the best-studied factor among the TGF-β family proteins, with its diversity of roles in the control of cell proliferation and differentiation, wound healing and immune system, and its key roles in pathology, for example, skeletal diseases, fibrosis, and cancer. Introduction: Transforming Growth Factor-Beta (TGF-β) is a master regulator of numerous cellular functions including cellular immunity. In cancer, TGF-β can function as a tumor promoter via several mechanisms including immunosuppression. Since the immune checkpoint pathways are co-opted in cancer " +
                "to induce T cell tolerance, this review posits that TGF-β is a master checkpoint in cancer, whose negative regulatory influence overrides and controls that of other immune checkpoints.Areas Covered: This review examines therapeutic agents that target TGF-β and its signaling pathways for the treatment of cancer which may be classifiable as checkpoint inhibitors in the broadest sense. This concept is supported by the observations that 1) only a subset of patients benefit from current checkpoint inhibitor therapies, 2) the presence of TGF-β in the tumor microenvironment is associated with excluded or cold tumors, and resistance to checkpoint inhibitors, and 3) existing biomarkers such as PD-1, PD-L1, microsatellite instability and tumor mutational burden are inadequate to reliably and adequately identify immuno-responsive patients. By contrast, TGF-β overexpression is a widespread and profoundly negative molecular hallmark in multiple tumor types.Expert Opinion: TGF-β " +
                "status may serve as a biomarker to predict responsiveness and as a therapeutic target to increase the activity of immunotherapies. The TGF-beta family of cytokines are ubiquitous, multifunctional and essential to survival. They play important roles in growth and development, inflammation and repair and host immunity. The mammalian TGF-beta isoforms (TGF-beta 1, beta 2 and beta 3) are secreted as latent precursors and have multiple cell surface receptors of which at least two mediate signal transduction. Autocrine and paracrine effects of TGF-beta's can be modified by extracellular matrix, neighbouring cells and other cytokines. The vital role of the TGF-beta family is illustrated by the fact that approximately 50% of TGF-beta 1 gene knockout mice die in utero and the remainder succumb to uncontrolled inflammation after birth. TGF-beta 2 and TGF-beta 3 gene knockout mice are not yet described. More recently, novel TGF-beta-like molecules have been described which " +
                "share some of the properties of the mammalian TGF-beta isoforms. The role of TGF-beta in homeostatic and pathogenic processes suggests numerous applications in the diagnosis and treatment of various diseases characterised by inflammation and fibrosis.";
        String cnStr0 = aLiEnToCnTrans(enStr, 100, gpuList);
        long t1 = System.currentTimeMillis();
        System.out.println("cnStr0:" + cnStr0 + " 用时:" + (t1 - t0));
        /**
         * cnStr0:转化生长因子 β（TGF-β）长期以来被认为与早期胚胎发育和器官发生，免疫监督，组织修复和成人体内平衡密切相关。 TGF-β 在纤维化和癌症中的作用是复杂的，有时甚至是矛盾的，根据疾病的阶段表现出抑制作用或促进作用。 在病理条件下, 过度表达的 TGF-β 引起上皮-间质转化 (EMT) 、细胞外基质 (ECM) 沉积、癌症相关的成纤维细胞 (CAF) 形成, 这导致纤维化疾病和癌症。 鉴于 TGF-β 及其下游分子在纤维化和癌症进展中的关键作用, 靶向 TGF-β 信号传导的疗法似乎是有希望的策略。 然而, 由于潜在的全身细胞毒性, TGF-β 治疗剂的开发已经滞后。 本文综述了 TGF-β 的生物学过程及其在纤维化和肿瘤发生中的双重作用，以及 TGF-β 靶向治疗的临床应用。 转化生长因子-β (TGF-β) 是生长和分化因子的 TGF-β 家族的原型, 其在哺乳动物中由 33 个基因编码并且包括同二聚体和异二聚体。 这篇综述向读者介绍了 TGF-β 家族的名称和生物学活性的复杂性。 它还介绍了 TGF-β 作为 TGF-β 家族蛋白中研究得最好的因子，其在控制细胞增殖和分化，伤口愈合和免疫系统中的作用具有多样性，并且在病理学中具有关键作用，例如，骨骼疾病，纤维化和癌症。 简介：转化生长因子-β（TGF-β）是许多细胞功能的主要调节剂，包括细胞免疫。 在癌症中，TGF-β 可以通过包括免疫抑制在内的几种机制充当肿瘤启动子。 由于免疫检查点通路在癌症中被选择以诱导 T 细胞耐受，因此本综述认为 TGF-β 是癌症中的主要检查点，其负面调节作用覆盖并控制了其他免疫检查点.涵盖的领域：本综述研究了针对 TGF-β 及其信号通路的治疗癌症的治疗剂，从最广泛的意义上讲，这些治疗剂可归类为检查点抑制剂。 以下观察结果支持了这一概念：1）只有一部分患者受益于当前的检查点抑制剂疗法； 2）肿瘤微环境中 TGF-β 的存在与排除或冷肿瘤以及对检查点抑制剂的抗性有关； 3）现有的生物标志物，例如 PD-1，PD-L1，微卫星不稳定性和肿瘤突变负荷不足以可靠且充分地鉴定免疫反应性患者。 相比之下，TGF-β 过表达是多种肿瘤类型中广泛存在的且极其阴性的分子标志.专家意见：TGF-β 状态可作为预测反应性的生物标志物和增加免疫疗法活性的治疗靶标。 细胞因子的 TGF-β 家族是普遍存在的、多功能的并且对于存活是必需的。 它们在生长和发育、炎症和修复以及宿主免疫中起重要作用。 哺乳动物 TGF-β 同种型 (TGF-β 1、β 2 和 β 3) 作为潜在前体分泌, 并具有多个细胞表面受体, 其中至少两个介导信号转导。 TGF-β 在稳态和致病过程中的作用表明在以炎症和纤维化为特征的各种疾病的诊断和治疗中的许多应用。  用时:9105
         */


        List<String> gpuList3090 = getGpuList3090();
        String cnStr1 = aLiEnToCnTrans(enStr, 100, gpuList3090);
        long t2 = System.currentTimeMillis();
        System.out.println("cnStr1:" + cnStr1 + " 用时:" + (t2 - t1));
        /**
         * cnStr1: 用时:19072
         */


        String cnStr2 = youDaoEnToCnTrans(enStr);
        long t3 = System.currentTimeMillis();
        System.out.println("cnStr2:" + cnStr2 + " 用时:" + (t3 - t2));
        /**
         * cnStr2:转化生长因子β (TGF-β)长期以来被证实与早期胚胎发育和器官发生、免疫监督、组织修复和成人稳态密切相关。TGF-β在纤维化和癌症中的作用是复杂的，有时甚至相互矛盾，根据疾病的分期表现为抑制或促进作用。在病理条件下，TGF-β过表达导致上皮间质转化(epithelial-mesenchymal transition, EMT)、细胞外基质(extracellular matrix, ECM)沉积、癌相关成纤维细胞(cancer-associated fibroblast, CAF)形成，从而导致纤维化疾病和癌症。鉴于TGF-β及其下游分子在纤维化和癌症进展中的关键作用，针对TGF-β信号转导的治疗似乎是一种有前途的策略。然而，由于潜在的全身细胞毒性，TGF-β疗法的发展滞后。本文就TGF-β的生物学过程及其在纤维化和肿瘤发生中的双重作用以及TGF-β靶向治疗的临床应用进行综述。转化生长因子-β (TGF-β)是TGF-β家族生长分化因子的原型，该家族由哺乳动物的33个基因编码，由同源二聚体和异源二聚体组成。这篇综述介绍了TGF-β家族及其名称和生物活性的复杂性。它还介绍了TGF-β作为TGF-β家族蛋白中研究最好的因子，在控制细胞增殖和分化、伤口愈合和免疫系统中发挥多种作用，并在骨骼疾病、纤维化和癌症等病理中发挥关键作用。简介:转化生长因子-β (TGF-β)是包括细胞免疫在内的多种细胞功能的主要调节因子。在癌症中，TGF-β可通过多种机制发挥肿瘤启动子的作用，包括免疫抑制。由于免疫检查点通路在癌症中被利用来诱导T细胞耐受，这篇综述假设TGF-β是癌症中的一个主检查点，它的负调控影响覆盖并控制其他免疫检查点的负调控影响。本综述探讨了靶向TGF-β及其信号通路治疗癌症的治疗药物，从广义上可以将其归类为检查点抑制剂。这一概念得到以下观察的支持:1)只有一小部分患者从目前的检查点抑制剂治疗中获益;2)肿瘤微环境中TGF-β的存在与排除或冷肿瘤、检查点抑制剂耐药性有关;3)现有的PD-1、PD-L1、微卫星不稳定性和肿瘤突变负担等生物标志物不足以可靠、充分地识别免疫应答患者。相比之下，TGF-β过表达在多种肿瘤类型中是一种广泛且深刻的负性分子特征。专家意见:TGF-β状态可作为预测免疫反应性的生物标志物，并可作为增加免疫治疗活性的治疗靶点。tgf - β细胞因子家族无处不在，多功能，对生存至关重要。它们在生长发育、炎症和修复以及宿主免疫等方面发挥着重要作用。哺乳动物tgf - β亚型(tgf - β 1， β 2和β 3)作为潜在的前体分泌，具有多个细胞表面受体，其中至少有两个介导的信号转导。tgf - β的自分泌和旁分泌作用可以被细胞外基质、邻近细胞和其他细胞因子修饰。大约50%的tgf - β 1基因敲除小鼠死于子宫内，其余小鼠在出生后死于不受控制的炎症，这一事实说明了tgf - β家族的重要作用。tgf - β 2和tgf - β 3基因敲除小鼠尚未被描述。最近，新的类似tgf - β的分子被描述出来，它们与哺乳动物的tgf - β异构体具有一些相同的性质。tgf - β在体内稳态和致病过程中的作用表明，在以炎症和纤维化为特征的各种疾病的诊断和治疗中有许多应用。 用时:842
         */

    }

    public static void test2() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(format.format(new Date()) + " 程序开始了~~~");
        List<String> gpuList = getGpuList();
        List<String> gpuList3090 = getGpuList3090();

        List<String> enList = new ArrayList<>();
        enList.add("TUMORITROPIC AND LYMPHOTROPIC PRINCIPLES OF MACROMOLECULAR DRUGS");
        enList.add("A generalization of hyperbolic Pascal triangles");
        enList.add("UNUSUAL COORDINATION AND METAL-LIGAND GEOMETRY OF A VANADYL PORPHYRIN IN AQUEOUS-SOLUTION");
        enList.add("Economics and Engineering: Institutions, Practices, and Cultures");
        enList.add("EVALUATION OF THE BENEFITS OF REFLECTORIZED SIGN POSTS TO DRIVERS");
        enList.add("Rare earth and transition metal based entropy stabilised perovskite type oxides");
        enList.add("On the application of \"spiral of silence\" theory in higher vocational Chinese teaching");
        enList.add("Dynamic Surface Control for Boiler Steam Pressure of Fuel-steam Pressure System");
        enList.add("Testing the relationship between intra-industry trade and economies of scale: the Case of China");
        enList.add("Study on some properties of Si-containing polyester-polyether multiblock copolymers");
        enList.add("Effect of polycyclic aromatic hydrocarbons on SAM-coated gold electrodes using ferricyanide as the redox indicator");
        enList.add("The prevalence of IG translocations and 7q32 deletions in splenic marginal zone lymphoma");
        enList.add("Soft Self-Healing Robot Driven by New Micro Two-Way Shape Memory Alloy Spring");
        enList.add("INTERLEUKIN-2 DEFECT IN THE PERIPHERAL-BLOOD AND THE LUNG IN PATIENTS WITH SJOGRENS-SYNDROME");
        enList.add("Single-Phase DC Crowbar Topologies for Low Voltage Ride Through Fulfillment of High-Power Doubly Fed Induction Generator-Based Wind Turbines");
        enList.add("[Electromyographic study of motility of the human digestive tract after various abdominal operations].");
        enList.add("AXIAL MIXING AND MASS-TRANSFER IN GAS-LIQUID KARR COLUMNS");
        enList.add("Psychoanalysis and 20th century Chinese literary theory");
        enList.add("RAISING AWARENESS FOR CHRONIC MESENTERIC ISCHEMIA: AN OFT-HIDDEN DIAGNOSIS");
        enList.add("South Korea's economy is growing faster than Mexico's");
        enList.add("Cardenolides of Leptadenia madagascariensis from the Madagascar dry forest");
        enList.add("SPECTROSCOPY OF ION-EXCHANGERS AND ITS APPLICATIONS - ION-EXCHANGER PHASE ABSORPTIOMETRY AND SPECTROFLUOROMETRY USING A CROSSLINKED DEXTRAN ION-EXCHANGER");
        enList.add("The effect of a Local isolate and Houghton strain of Eimeria tenella on clinical and growth parameters following challenge in chickens vaccinated with IMMUCOX ® and LIVACOX ® vaccines.");
        enList.add("Adalimumab to treat recalcitrant dissecting cellulitis of the scalp");
        enList.add("Establishment of Chemiluminescence Immunoassay for the Detection of Peste des Petits Ruminants Virus H Protein Antibodies");
        enList.add("Studies on experimental growth retardation in sheep. The effect of removal of a endometrial caruncles on fetal size and metabolism.");
        enList.add("Damage Effectiveness Analysis of Submunition against Aircraft Carrier ( Ⅲ )——Damage Effectiveness Analysis of Submunition against shipboard Aircraft Group");
        enList.add("Improve the efficiency of hospital service by day operation management");
        enList.add("INGAAS METAL-SEMICONDUCTOR-METAL PHOTODETECTORS FOR LONG WAVELENGTH OPTICAL COMMUNICATIONS");
        enList.add("A preview of the 2018 panel topics in the Journal of Practical Obstetrics and Gynecology");
        enList.add("Somatic second-hit mutations leads to polycystic liver diseases");
        enList.add("SOME THOUGHTS ON SCHIZOPHRENIA IN CHILDHOOD");
        enList.add("Itraconazole improves survival outcomes in patients with colon cancer by inducing autophagic cell death and inhibiting transketolase expression");
        enList.add("On October 23, 2019, \"A Dream of Red Mansions\" Research Base of Minzu University of China was opened at Cao Xueqin Institute in Beijing");
        enList.add("Redology research should be diversified");
        enList.add("Injection of CBTX-A in the treatment of spastic cerebral palsy");
        enList.add("[Legislation & sanitary aspects of family vacation houses].");
        enList.add("On Sample-Path Optimal Dynamic Scheduling for Sum-Queue Minimization in Trees Under the K-Hop Interference Model");
        enList.add("Risk and prevention of off-label drug uses");
        enList.add("[Amplification and inhibition of platelet function by serum lipoproteins].");
        enList.add("AN APPLICATION OF SELECTIVE LASER IONIZATION FOR THE DETERMINATION OF POTASSIUM IN FLAME");
        enList.add("The departure interval of Beijing Metro Line 13 will be reduced to 4 minutes");
        enList.add("Edge tension control of wool fabric");
        enList.add("Hyponormality for commuting pairs of operators");
        enList.add("Recycle Rare Earth Elements from NdFeB Waste with Oxalate Precipitation Method");
        enList.add("Small Median Sternotomy for Aortic CValve Replacement");
        enList.add("Clinical analysis of 13 cases of cerebellar hemorrhage");
        enList.add("Five cases of heart penetrating injury were rescued by small incision in chest");
        enList.add("JANACEK THE 'MAKROPOULOS CASE'");
        enList.add("YERSINIA ENTEROCOLITICA SEPTICEMIA");


        enList.parallelStream().forEach(enStr -> {
            String cnStr0 = aLiEnToCnTrans(enStr, 100, gpuList);
            System.out.println("cnStr0:" + cnStr0);
        });
        enList.parallelStream().forEach(enStr -> {
            String cnStr2 = youDaoEnToCnTrans(enStr);
            System.out.println("cnStr2:" + cnStr2);
        });

//        for (String enStr : enList) {
//            String cnStr0 = aLiEnToCnTrans(enStr, 100, gpuList);
//            System.out.println("cnStr0:" + cnStr0);
//        }
//
//        for (String enStr : enList) {
//            String cnStr1 = aLiEnToCnTrans(enStr, 100, gpuList3090);
//            System.out.println("cnStr1:" + cnStr1);
//        }
//
//        for (String enStr : enList) {
//            String cnStr2 = youDaoEnToCnTrans(enStr);
//            System.out.println("cnStr2:" + cnStr2);
//        }


    }


// end
}
